
module.exports = (app) => {
    const { controller, adminRouter } = app;
    // controller.admin.LoginController.login  通过文件名查找道对应的方法
    // controller.admin.loginController.login 文件名会被转为小写，所以遵循小写文件名
    // 测试用
    adminRouter.get('/user/login', controller.admin.loginController.login)
    // 用户登录
    adminRouter.post('/user/login', controller.admin.userController.login);
    // 用户
    adminRouter.get("/user/list", controller.admin.userController.queryUser)
    adminRouter.put("/user/create", controller.admin.userController.createUser)
    adminRouter.delete("/user/delete/:id", controller.admin.userController.deleteUser)

    // 产品
    adminRouter.get("/user/product/list", controller.admin.productCtrl.queryProduct)
    adminRouter.put("/user/product/create", controller.admin.productCtrl.createProduct)
    adminRouter.post("/user/product/update", controller.admin.productCtrl.updateProduct)
    adminRouter.delete("/user/product/delete/:id", controller.admin.productCtrl.deleteProduct)
    // 表的增删改查
    adminRouter.get("/user/table/list", controller.admin.tableController.queryTable)
    adminRouter.put("/user/table/create", controller.admin.tableController.createTable)
    adminRouter.post("/user/table/update", controller.admin.tableController.updateTable)
    adminRouter.delete("/user/table/delete/:id", controller.admin.tableController.deleteTable)

    // api 接口分类
    adminRouter.get("/user/api/category/list", controller.admin.categoryCtrl.queryCategory)
    adminRouter.put("/user/api/category/create", controller.admin.categoryCtrl.createCategory)
    adminRouter.post("/user/api/category/update", controller.admin.categoryCtrl.updateCategory)
    adminRouter.delete("/user/api/category/delete/:id", controller.admin.categoryCtrl.deleteCategory)

    // api 接口管理 接口层属性接口分类下，所以要传入相关的接口分类id
    adminRouter.get("/user/api/list/:id", controller.admin.apiCtrl.queryApi)
    adminRouter.put("/user/api/create", controller.admin.apiCtrl.createApi)
    adminRouter.post("/user/api/update", controller.admin.apiCtrl.updateApi)
    adminRouter.delete("/user/api/delete/:id", controller.admin.apiCtrl.deleteApi)


    // api 接口数据管理
    adminRouter.get("/user/api/data/list", controller.admin.apiDataCtrl.queryApi)
    adminRouter.get("/user/api/data/:id", controller.admin.apiDataCtrl.queryApiById)
};